/*
  Copyright 1996-2003
  Simon Whiteside

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


  $Id: StackFrame.java,v 1.3 2003/02/24 18:10:53 simkin_cvs Exp $
*/

package simkin;	
import java.util.Hashtable;

/**
 * This class stores information about the where the current script is executing.
 * This class is used internally by the {@link simkin.Interpreter Interpreter}, you do not normally need to use it.
 */

public class StackFrame {
    /** Constructor
     * @param location the name of the source file
     * @param obj the object owning the script
     * @param vars the local variables at this part of the script
     * @param ctxt the current ExecutableContext
     */
    public StackFrame(String location,Object obj,Hashtable vars,ExecutableContext ctxt ){
	m_Location=location;
	m_Object=obj;
	m_Vars=vars;
	m_Context=ctxt;
	m_LineNum=0;
	ctxt.pushStackFrame(this);
    }
    /** updates the line number for the frame 
     * @param line_num the new line number
     */
    public void setLineNum(int line_num){
	m_LineNum=line_num;
    }
    /** returns the current line number 
     * @return the current line number in the script
     */
    public int getLineNum(){
	return m_LineNum;
    }
    /** returns the location of the code being executed in this stack frame 
     * @return the current name of the script
     */
    public String getLocation(){
	return m_Location;
    }
    /** returns the context within which the stack frame is executing 
     * @return the owning ExecutableContext
     */
    public ExecutableContext getContext(){
	return m_Context;
    }
    /** returns the object owning the stack frame 
     * @return the owning object
     */
    public Object getObject(){
	return m_Object;
    }
    /** returns the local variables for this stack frame 
     * @return the current local variables
     */
    public Hashtable getVars(){
	return m_Vars;
    }
    /** returns the parent frame of this one 
     * @return the StackFrame that called this one
     */
    public StackFrame getParentFrame(){
	return m_ParentFrame;
    }
    /** sets the parent frame of this frame 
     * @param frame set the parent stack frame
     */
    public void setParentFrame(StackFrame frame){
	m_ParentFrame=frame;
    }
    /** location during script execution */
    private String m_Location;
    /** line number during script execution */
    private int m_LineNum;
    /** object owning this stack frame */
    private Object m_Object;
    /** local variables for the stack frame */
    private Hashtable m_Vars;
    /** context within which the stack frame is executed */
    private ExecutableContext m_Context;
    /** the parent frame of this stack frame */
    private StackFrame m_ParentFrame;
}
